package com.mayikt.main.api.impl.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 余胜军  备胎rabbitmq相关配置
 * @ClassName RabbitMQSpareTireConfig
 * @qq 644064779
 * @addres www.mayikt.com
 * 微信:yushengjun644
 */
@Configuration
public class RabbitMQSpareTireConfig {
    /**
     * 定义交换机
     */
    public static final String EXCHANGE_SPARETIRE_MAYIKT_NAME = "/mayikt_sparetire_ex";

    /**
     * 唯一登录队列 日志功能(备胎)
     */
    public static final String MAYIKT_SPARETIRE_UNIQUELOGIN_QUEUE = "fanout_sparetire_uniquelogin_queue";

    /**
     * 配置MAYIKT_UNIQUELOGIN_QUEUE
     *
     * @return
     */
    @Bean
    public Queue fanoutSparetireUniqueloginQueue() {
        return new Queue(MAYIKT_SPARETIRE_UNIQUELOGIN_QUEUE);
    }

    /**
     * 配置fanoutExchange
     *
     * @return
     */
    @Bean
    public FanoutExchange fanoutSparetireExchange() {
        return new FanoutExchange(EXCHANGE_SPARETIRE_MAYIKT_NAME);
    }


    // 绑定交换机 fanoutUniqueloginQueue
    @Bean
    public Binding bindingUniqueLogFanoutExchange(Queue fanoutSparetireUniqueloginQueue, FanoutExchange fanoutSparetireExchange) {
        return BindingBuilder.bind(fanoutSparetireUniqueloginQueue).to(fanoutSparetireExchange);
    }
}
